<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <script src="./js/earthsdk.js"></script>
    <!-- 自定义Css样式 -->
    <link rel="stylesheet" href="./css/example1.css">
    <title>Cesium地球初始化</title>
    <style>
        html,
        body,
        #app {
            width: 100%;
            height: 100%;
            margin: 0px;
            padding: 0px;
        }

        .box {
            display: grid;
            align-items: center;
            grid-template-columns: 100px 1fr;
            grid-row-gap: 5px;
            margin-bottom: 10px;
            grid-template-rows: 32px;
        }

        .box>div {
            display: grid;
            grid-template-columns: 0.5fr 0.5fr;
        }

        .box>div>input {
            width: 88px !important;
        }


        .box1 {
            display: grid;
            align-items: center;
            grid-template-columns: 1fr;
        }
    </style>
</head>

<body>
    <div id="app"></div>
    <script src="https://cdn.jsdelivr.net/npm/echarts@5.2.2/dist/echarts.min.js"></script>

    <script>
        /** ---------------------------------地球创建------------------------------------**/

        // Vue中引入方式：import { ESObjectsManager } from 'esobjs-xe2-plugin/dist-node/esobjs-xe2-plugin-main';

        const { ESObjectsManager } = XE2['esobjs-xe2-plugin-main']
        const objm = new ESObjectsManager();
        window.g_objm = objm;
        // 创建Cesium视口
        const viewer = objm.createCesiumViewer({
            domid: document.getElementById("app"),
        });
        viewer.ionAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyZmQzMDI1OC1kMWYyLTQ1ZjEtYTJmNS0yMjY1ZDcxZjEyOTkiLCJpZCI6NjQ3MTgsImlhdCI6MTYyOTQzNDM5M30.m8vkzG05QiAfe6JQ0XPK8z_6KuUVMf_CoSY-YlMnAIg"
        // 监听视口状态
        viewer.statusChanged.don(status => {
            if (status == 'Created') {
                // 视口创建完成，飞到初始视角位置
                objm.activeViewer.flyIn([
                    114.2794204306266,
                    28.437726297104202,
                    2450.8022006307774
                ], [
                    359.9999999999998,
                    -89.93071549349989,
                    0
                ], 3)
            }
        })
        // 通过json创建一个影像图层
        const imageryLayer = objm.createSceneObjectFromJson({
            "id": "9812a65f-0de0-4f7b-b234-809c0c2fb8ef",
            "type": "ESImageryLayer",
            "maximumLevel": 18,
            "url": "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
        });

        /** ---------------------------------文字标记------------------------------------**/

        const { ESGeoDiv } = XE2['esobjs-xe2-plugin-main']
        const sceneObject = objm.createSceneObject(ESGeoDiv)

        sceneObject.position = [114.28193082318909, 28.43803979736081, 0]

        sceneObject.instanceClass = class MyDiv {
            // container是Poi的div
            // eSGeoDiv指向当前的GeoCustomDivPoi场景对象
            // viewer指定当前的视口
            constructor(container, eSGeoDiv, viewer) {
                this._container = container;
                this._div = document.createElement('div');
                this._div.style.width = '250px'
                this._div.style.height = '250px'
                this._div.style.backgroundColor = 'rgba(0,0,0,0)'
                var chart = echarts.init(this._div);
                chart.setOption({
                    color: ['#3D91F7', '#61BE67'],
                    radar: {
                        radius: '80%',
                        triggerEvent: true,
                        name: {
                            textStyle: {
                                color: '#fff',
                                fontSize: '13',
                            }
                        },
                        nameGap: '2',
                        indicator: [
                            { name: '动火', max: 10 },
                            { name: '受限空间', max: 10 },
                            { name: '盲板抽堵', max: 10 },
                            { name: '高处作业', max: 10 },
                            { name: '吊装', max: 10 },
                            { name: '动土', max: 10 },
                            { name: '短路', max: 10 },
                            { name: '临时用电', max: 10 }
                        ],
                        splitArea: {
                            areaStyle: {
                                color: [
                                    'rgba(0, 255, 255, 0.1)', 'rgba(0, 255, 255, 0.2)',
                                    'rgba(0, 255, 255, 0.3)', 'rgba(0, 255, 255, 0.4)',
                                    'rgba(0, 255, 255, 0.5)', 'rgba(0, 255, 255, 0.6)'
                                ].reverse()
                            }
                        },
                        axisLine: { //指向外圈文本的分隔线样式
                            lineStyle: {
                                color: 'rgba(0,0,0,0)'
                            }
                        },
                        splitLine: {
                            lineStyle: {
                                width: 2,
                                color: 'transparent'
                            }
                        },
                        label: {
                            position: 'inside'
                        }
                    },
                    series: [{
                        name: '安全作业',
                        type: 'radar',
                        itemStyle: {
                            borderColor: 'rgba(66, 242, 185, 1)',
                            color: '#fff',
                            fontSize: 12
                        },
                        areaStyle: {
                            normal: {
                                color: 'rgba(0, 255, 255, 1)'
                            }
                        },
                        symbolSize: 10,
                        lineStyle: {
                            normal: {
                                color: 'rgba(252,211,3, 1)',
                                width: 1
                            }
                        },
                        data: [{
                            value: [7, 2, 0, 0, 0, 0, 0, 6],
                            name: '作业',
                        }
                        ]
                    }]
                })
                this._container.appendChild(this._div)
            }
            // 销毁函数，注意此函数必需，否则会报错！
            destroy() {
                this._container.removeChild(this._div);
            }
        }

    </script>

    <!-- 切换UE和Cesium引擎的组件（Vue） -->
    <div id="root">
        <switch-engine :objm="objm"></switch-engine>
    </div>
    <!-- Vue文件 -->
    <script src="./js/vue.global.js"></script>
    <!-- 切换UE和Cesium的组件 -->
    <script src="./js/switchEngineCom.js"></script>
</body>

</html>